package com.wteam.controller;


import com.wteam.PoJo.DTO.OrderDetailDTO;
import com.wteam.PoJo.DTO.OrderFormDTO;
import com.wteam.PoJo.DTO.orderpageDTO;
import com.wteam.Service.IOrderDetailService;
import com.wteam.Service.IOrderService;
import com.wteam.until.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单表（现货） 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-07-16
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单模块")
public class OrderController {
    @Autowired
    private IOrderService iOrderService;

    @PostMapping("/savecartorder")
    @ApiOperation("添加订单（购物车）")
    public Result createcartorder(@RequestBody OrderFormDTO orderFormDTO) {
        iOrderService.saveoreder(orderFormDTO);
        return Result.success();
    }
    @PostMapping("/saveorder")
    @ApiOperation("添加订单（直接购买）")
    public Result createorder(@RequestBody OrderFormDTO orderFormDTO) {
        iOrderService.oreder(orderFormDTO);
        return Result.success();
    }

    @PostMapping("/orderbystatus")
    @ApiOperation("查看订单")
    public Result orderbystatus(@RequestBody orderpageDTO orderpageDTO) {
      return   iOrderService.orderbystatus(orderpageDTO);

    }

    @GetMapping("/buyorder/{orderid}")
    @ApiOperation("更改订单状态(传订单id)")
    public Result orderbystatus(@PathVariable Long orderid) {
        return   iOrderService.buyorder(orderid);
    }


}
